package com.jielin.handling.service.dict.impl;

import java.util.HashMap;
import java.util.List;

import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.jielin.handling.entity.dict.Dict;
import com.jielin.handling.mapper.dict.DictMapper;
import com.jielin.handling.service.dict.DictService;

import lombok.extern.slf4j.Slf4j;

@Service
@Slf4j
public class DictServiceImpl implements DictService {
	@Autowired
	private DictMapper dictMapper;
	
	@Override
	public Dict getDictByCode(String code) {
		log.info("code={}", JSONObject.toJSONString(code));
		return dictMapper.getDictByCode(code);
	}

	@Override
	public HashMap getListByParentCode(String parentCode) {
		log.info("parentCode={}",JSONObject.toJSONString(parentCode));
		HashMap map=new HashMap();
		String str[]=parentCode.split(",");
		for(int i=0;i<str.length;i++){
			List<Dict> list=dictMapper.getListByParentCode(str[i]);
			map.put(String.valueOf(i),list);
		}
		return map;
	}

}
